%{
#include "cmd.tab.c"

extern char* yylval;
%}
string [A-Za-z][A-Za-z0-9]*
filename [\../]*[A-Za-z][A-Za-z0-9][A-Za-z0-9\.A-Za-z0-9]*
integer [0-9]+

ipproto (tcp)|(udp)|(unix)|(any)
ipaddr [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}
macaddr [0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}

iprange {ipaddr}-{ipaddr}
portrange {integer}-{integer}

%%
[ \t]+  ;
[/;] 		 return TERMINATOR;

"setup"      return SETUP;
"commit"     return COMMIT;
"rollback"   return ROLLBACK;
"print"  	 return PRINT;
"export" 	 return EXPORT;
"?"          return HELP;
"help"       return HELP;
"exit"   	 return SERVER_EXIT;
"quit"   	 return EXIT;

"l7" 	 	 return L7;
"l7_default" return L7_DEFAULT;
"filter" 	 return FILTER;
"java"   	 return JAVA;
"system" 	 return SYSTEM;
"memory" 	 return MEMORY;
"ct"     	 return CT;
"topology"   return TOPOLOGY;
"module" 	 return MODULE;
"module_default" return MODULE_DEFAULT;
"server"  	 return SERVER;
"thread" 	 return THREAD;
"pcap"   	 return PCAP;

"add"    	 return ADD;
"del"    	 return DEL;
"clear"  	 return CLEAR;

{ipproto} { yylval = strdup(yytext); return IPPROTO; }

{integer} { yylval = strdup(yytext); return INTEGER; }
{string} { yylval = strdup(yytext); return STRING; }
{filename} { yylval = strdup(yytext); return FILENAME; }

{ipaddr} { yylval = strdup(yytext); return IPADDR; }
{macaddr} { yylval = strdup(yytext); return MACADDR; }

{iprange} { yylval = strdup(yytext);  return IPRANGE; }
{portrange} { yylval = strdup(yytext);  return PORTRANGE; }

%%

int yywrap() {
	return 1;
}
